package com.demo.pattern.simplefactory.order;

import com.demo.pattern.simplefactory.pizza.CheesePizza;
import com.demo.pattern.simplefactory.pizza.GreekPizza;
import com.demo.pattern.simplefactory.pizza.Pizza;

/**
 * @author sourire
 * @version 1.0
 * @date 2020/8/18 11:25
 */
public class OrderPizza {
    private String orderType;
    private Pizza pizza;

    public OrderPizza(String orderType){
        this.orderType = orderType;
    }

    public void creatPizza(){
        if(orderType.equals("greek")){
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        }else if(orderType.equals("cheese")){
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        }
        if(pizza == null){
            System.out.println("你要的披萨不存在");
        }else{
            pizza.makePizza();
        }
    }
}
